package com.mtons.mblog.base.utils;

import org.springframework.lang.Nullable;

import java.util.regex.Pattern;

public class EmailUtils {
    public EmailUtils() {
    }

    //判断邮箱是否有效
    public void validateEmail(String email, @Nullable Object type, String message) {
        String pattern = "[A-Za-z0-9]+@\\w{2,5}\\.com";
        boolean isMatch = Pattern.matches(pattern, email);
        if (isMatch == false) {
            throw new IllegalArgumentException("请填写正确的邮箱地址");
        }
        if(type == null){
            throw new IllegalArgumentException(message);
        }
    }

    //
}
